package com.kai.service.data;

import lombok.AccessLevel;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldDefaults;

import java.io.Serializable;

@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
@NoArgsConstructor
public class Result<T> implements Serializable {

    private static final long serialVersionUID = -8676181355403088497L;

    /**
     * 调用是否正常
     */
    boolean success;

    /**
     * 返回对象
     */
    T body;

    /**
     * 返回码，错误码
     */
    int code;

    /**
     * 返回消息
     */
    String msg;

    public Result(int code, String msg, boolean success) {
        this.code = code;
        this.success = success;
        this.msg = msg;
    }

    public Result(int code, String msg, boolean success, T body) {
        this.code =code;
        this.success = success;
        this.msg = msg;
        this.body = body;
    }
}
